package com.audible.library.domain.beans;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * This is a lightweight persistence domain object representing primary key in user_audio_book table in the database.
 *
 * @author Jigar Shah
 * @version 0.1
 */
@Embeddable
public class UserAudioBookPK implements Serializable {

    private static final long serialVersionUID = -5885137481503559547L;

    @Basic(optional = false)
    @Column(name = "USER_PROFILE_ID")
    private int userProfileId;

    @Basic(optional = false)
    @Column(name = "AUDIO_BOOK_ID")
    private int audioBookId;

    public UserAudioBookPK() {
    }

    public UserAudioBookPK(int userProfileId, int audioBookId) {
        this.userProfileId = userProfileId;
        this.audioBookId = audioBookId;
    }

    public int getUserProfileId() {
        return userProfileId;
    }

    public void setUserProfileId(int userProfileId) {
        this.userProfileId = userProfileId;
    }

    public int getAudioBookId() {
        return audioBookId;
    }

    public void setAudioBookId(int audioBookId) {
        this.audioBookId = audioBookId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) userProfileId;
        hash += (int) audioBookId;
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UserAudioBookPK)) {
            return false;
        }
        UserAudioBookPK other = (UserAudioBookPK) object;
        if (this.userProfileId != other.userProfileId) {
            return false;
        }
        if (this.audioBookId != other.audioBookId) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.audible.library.domain.beans.UserAudioBookPK[userProfileId=" + userProfileId + ", audioBookId=" + audioBookId + "]";
    }

}
